package com.lifeng.interfaceprocess;

import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

@Component
public class SaveInitDemo implements ApplicationContextAware, InitializingBean,ApplicationEventPublisherAware{
	public static ApplicationContext applicationContext = null;
	
	@Override
	public void afterPropertiesSet() throws Exception {
		//获取某个接口的所有实现类
		Map<String,DataBaseService> maps = applicationContext.getBeansOfType(DataBaseService.class);
		System.out.println(maps);
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		//可以获得事件发布器
	}

}
